package com.block.account.enums;

import cn.hutool.core.util.StrUtil;
import com.block.common.enums.BaseEnum;
import lombok.Getter;

@Getter
public enum AccountTypeEnum implements BaseEnum {

    CHAN("CHAN", "渠道"),
    PROD("PROD", "产品"),
    SPECIAL("SPECIAL", "机构"),
    FORM("FORM", "表单"),
    ACCOUNT("ACCOUNT", "总账列表"),
    ;

    String value;
    String name;

    AccountTypeEnum(String value, String name){
        this.value = value;
        this.name = name;
    }

    @Override
    public String getValue() {
        return this.value;
    }

    @Override
    public String getLabel() {
        return this.name;
    }

    @Override
    public String getLabelByValue(String value) {
        for (AccountTypeEnum accountTypeEnum : values()) {
            if (StrUtil.equals(accountTypeEnum.getValue(), value)){
                return accountTypeEnum.getLabel();
            }
        }
        return value;
    }

    public AccountTypeEnum getEntryByValue(String value) {
        for (AccountTypeEnum accountTypeEnum : values()) {
            if (StrUtil.equals(accountTypeEnum.getValue(), value)){
                return accountTypeEnum;
            }
        }
        return null;
    }
}
